-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soft enforcement of unit quaternions for node.rotation #971
Conversation
Looks like we should also restrict values of |
Although it isn't typical, that is still a valid scale and will create a valid transform matrix, right? |
That depends on how we define "valid transform matrix". Scale of |
Is this going to cause an issue? I can easily imagine an animation changing the scale to zero for a number of scenarios. It might not have the correct result if this is not allowed. Even if it did have the correct result, it would be a pain to have to tweak the animation to scale to something close to zero. |
We could add a non-normative/implementation note that states transform matrices may have a zero scale and therefore may will not be invertible in these cases. |
Strictly speaking, such matrix will not be decomposable to TRS (btw, we require this from
So engines won't be able to get normal matrix, right? |
True, but is this a problem? Animations can only target TRS anyways. The matrix form will be unable to specify a scale of zero. |
In that case, right. |
Since But static transforms are ambiguous. |
Is there any reasonable way to allow scaling to |
Should this be expected behavior for other renderers? Other options include:
|
Sounds OK. Remember it's not just normal vectors that are undefined: All of the polygons become co-planar, so depth buffering may be undefined as well. |
Thanks for looking into Unity, @bghgary! I suspect this was not designed intentionally in Unity.
Could be OK, but we try to minimize undefined behavior, so why not go with
unless we have a good use case for this? Paper Mario? 😄 |
BabylonJS does this if I force the x-scale to zero: Note the z-fighting with the triangles. I think whatever we do here, it will be an implementation note. I don't think we should restrict this in the spec. I would probably leave it as undefined. Practically, I doubt anyone will do this. @snagy and I just noticed another thing we probably should specify in the spec. When an odd number of scale components are negative, the faces of the triangles should be flipped. This works correctly in Unity but not currently in BabylonJS. Making the scale negative is useful for mirroring. |
We assume here, that mirroring is more usable, than flipping object inside-out, right? |
Yes. I suppose there might be a use case for double-sided materials, but it will be uncommon.
My understanding is that the determinant of the matrix can be used to decide whether to flip the faces or not. Chapter 3.1.2 of Mathematics for 3D Game Programming and Computer Graphics by Eric Lengyel describes this. The gist of it is that if the determinant is negative, then the handedness is reversed, which means the faces should be flipped. @snagy checked Unreal's implementation and that's what it does. |
Relying on determinant sounds good (I was a bit confused by counting the number of negative scale components). Could you please update this PR with a note on these topics (zero/negative determinant)? |
I created a separate PR. Hope that's okay. |
Sadly, we can't check quaternion's length with schema, but it's still better than nothing.